home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Programming / MT2Trivial 2.1.3 / MT2Trivial 2.1.3 ƒ / MT2Trivial Templates ƒ / MainLoop.c.Trivial < prev    next >
Encoding:
Text File  |  1996-08-09  |  1.7 KB  |  117 lines  |  [TEXT/MPS ]

  1.  
  2. //%%DOC: MainLoop.c.Trivial -- begin
  3.  
  4.  
  5. void Init(void);
  6. void MainLoop (void);
  7. void DoMouseDown (EventRecord *event);
  8.  
  9. void Init()
  10. {
  11.     MaxApplZone();
  12.     
  13.     InitGraf(&thePort);
  14.     InitFonts();
  15.     InitWindows();
  16.     InitMenus();
  17.     TEInit();
  18.     InitDialogs(0L);
  19.     InitCursor();
  20.     FlushEvents(everyEvent, 0);
  21. %IF.TRIVIAL.RES MBAR
  22.        DoMakeMenus ();
  23. %END.TRIVIAL
  24.   
  25.       //%% >> add another initialization here <<
  26.  
  27. }/* end Init */
  28.  
  29.  
  30. void MainLoop ()
  31. {
  32.     RgnHandle    cursorRgn;
  33.     Boolean    gotEvent,quit;
  34.     EventRecord    event;
  35.     char key;
  36.  
  37.     cursorRgn = NewRgn();     // Pass empty region 1st time thru
  38.  
  39.     gotEvent = false;
  40.     quit = false;
  41.     while ( quit == false )
  42.     {
  43.         gotEvent = WaitNextEvent(everyEvent, &event, 15,cursorRgn);
  44.          if (gotEvent)
  45.           switch (event.what)
  46.             {
  47.             case mouseDown:
  48.                 DoMouseDown(&event);
  49.                 break;
  50.                             
  51.             case keyDown: 
  52.             case autoKey:
  53.                 key = (event.message & charCodeMask);
  54.                 if ((event.modifiers & cmdKey) != 0)
  55.                   {
  56.                   /*%% >> <<*/;
  57.                   }
  58.                 break;
  59.                 
  60.             case updateEvt:
  61.                   {
  62.                   /*%% >> <<*/;
  63.                   }
  64.                 break;
  65.                 
  66.             case activateEvt:
  67.                   {
  68.                   /*%% >> <<*/;
  69.                   }
  70.                 break;
  71.             }
  72.             
  73.     }
  74.  DisposeRgn(cursorRgn);
  75. }/* end MainLoop */
  76.  
  77.  
  78. void DoMouseDown (EventRecord *event)
  79. {
  80.     WindowPtr    theWindow;
  81.     int            windowCode = FindWindow (event->where, &theWindow);
  82.     
  83.     switch (windowCode)
  84.       {
  85.       case inSysWindow: 
  86.         SystemClick (event, theWindow);
  87.         break;
  88.  
  89. %IF.TRIVIAL.RES MBAR                        
  90.       case inMenuBar:
  91.         DoMenuCommand(event);
  92.         break;
  93. %END.TRIVIAL 
  94.         
  95.       case inDrag:
  96.             /*%% >> <<*/
  97.             break;
  98.             
  99.       case inContent:
  100.             /*%% >> <<*/
  101.           break;
  102.           
  103.       case inGoAway:
  104.             /*%% >> <<*/
  105.             break;
  106.       }
  107. }/* end DoMouseDown */
  108.  
  109. void    main( void )
  110. {
  111.     Init();    
  112.     MainLoop();
  113. } /* end main */
  114.  
  115.  
  116. //%%DOC: MainLoop.c.Trivial -- eof
  117.